#include <config>

#ifdef _OSGIS_IN_TEST

#include <layer>

#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/Notify>
#include <osg/Vec3f>

#include <ctl>
#include <hudUtil>
#include <lua>
#include <luabind/luabind.hpp>

#include <iostream>
using namespace std;

lua_State* lua;

namespace boost {
	template<typename T>
	static T* get_pointer(osg::ref_ptr<T> const & ptr) {
		return ptr.get();
	}

}
void registerOsg(lua_State* lua)
{
	using namespace luabind;
	module(lua)
		[
			class_<osg::Vec3f>("Vec3f")
			.def(constructor<>())
			.def(constructor<float, float, float>())
			.def("valid", &osg::Vec3f::valid)
			.def("set", (void(osg::Vec3f::*)(float, float, float))&osg::Vec3f::set),

			class_<osg::Node, osg::ref_ptr<osg::Node>>("Node")
			.def(constructor<>())
		];
}

void callLua()
{
	using namespace luabind;
	lua_tinker::dofile(lua, "scripts/t.lua");
	try
	{
		luabind::object luaTable = luabind::globals(lua)["meta"] ; 
		for (luabind::iterator i(luaTable), end; i != end; ++i) 
		{ 
			luabind::object o = *i;
			cout<<o["Name"]<<endl;
		} 
	}
	catch(...)
	{
		cout<<"Err!!"<<endl;
	}
}

int main(int argc, char* argv[])
{
	cout<<"Lua Bind Test!!\n";
	lua = lua_open();
	luaopen_base(lua);
	luaopen_string(lua);

	registerOsg(lua);

	lua_close(lua);
	cout<<"Done!\n";
	return 0;
}

#endif